<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="../static/jquery-1.7.1.min.js"></script>
</head>
<body>
<img id="qrCode" src="">
</body>
<script>
    let signature = Math.random().toString().slice(-6);
    $(function () {
        $.ajax({
            url: "/wx/createQrCode?signature=" + signature,
            type: "get",
            success: function (data) {
                console.log(data)
                $("#qrCode").attr('src', data);
            }
        })
    })

    //每3秒执行一次setFunction()方法
    let Ts = window.setInterval(whetherTheLogin, 1000 * 3);

    let i = true;

    function whetherTheLogin() {
        $.ajax({
            url: "/wx/whetherTheLogin?signature=" + signature,
            type: "get",
            success: function (data) {
                if (data) {
                    alert("登录成功！");
                    //当超过一定时间时
                    window.clearInterval(Ts);//杀掉这个进程
                }
            }
        })
    }

</script>
</html>